<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "/admin/include/head.htm">
<#include "/admin/include/upload.ftl">
<script type="text/javascript" src="${base}/resource/js/input.js"></script>
<script type="text/javascript" src="${base}/resource/thirdparty/colorpicker/js/colorpicker.js"></script>
<link rel="stylesheet" href="${base}/resource/thirdparty/colorpicker/css/colorpicker.css" type="text/css" />
<title>站点设置</title>
<script type="text/javascript">
	$(function(){
		var $validateForm = $("#validateForm");   
		//表单底部按钮 
    	LG.setFormDefaultBtn(f_cancel, function(){
			$validateForm[0].submit();
		});
		$("#tabcontainer").ligerTab();
		var $validateErrorContainer = $("#validateErrorContainer");
		var $validateErrorLabelContainer = $("#validateErrorContainer ul");
		
		$("#logoBtn").browser({
			uploadType:'logo',
			"callback" : function(url, store_path) {
				$(".preImg").attr('src',url);
				$(".preImg").parent().attr('href',url);
				$("#logo").val(url);
			}
		});
		
		$("#defaultImgBtn").browser({
			"callback" : function(url, store_path) {
				$(".preImg_d").attr('src',url);
				$(".preImg_d").parent().attr('href',url);
				$("#defaultImg").val(url);
			}
		});

		// 表单验证
		$validateForm.validate({
			errorContainer: $validateErrorContainer,
			errorLabelContainer: $validateErrorLabelContainer,
			wrapper: "li",
			errorClass: "validateError",
			ignoreTitle: true,
			ignore: ".ignoreValidate",
			rules: {
				"name": "required",
				"url": "required",
				"logo": "imageFile",
				"email": "email",
				"loginFailureLockCount": {
					required: true,
					positiveInteger: true
				},
				"loginFailureLockTime": {
					required: true,
					digits: true
				},
				"smtpFromMail": {
					required: true,
					email: true
				},
				"smtpHost": "required",
				"smtpPort": {
					required: true,
					digits: true
				},
				"smtpUsername": "required",
				"currencyType": "required",
				"currencySign": "required",
				"currencyUnit": "required",
				"storeAlertCount": {
					required: true,
					digits: true
				},
				"buildHtmlDelayTime": {
					required: true,
					digits: true
				}
			},
			messages: {
				"name": "请填写网店名称",
				"url": "请填写网店网址",
				"logo": "网店LOGO格式错误",
				"email": "E-mail格式不正确",
				"loginFailureLockCount": {
					required: "请填写连续登录失败最大次数",
					positiveInteger: "连续登录失败最大次数请输入合法的正整数"
				},
				"loginFailureLockTime": {
					required: "请填写自动解锁时间",
					digits: "自动解锁时间必须为零或正整数"
				},
				"smtpFromMail": {
					required: "请填写发件人邮箱",
					email: "发件人邮箱格式错误"
				},
				"smtpHost": "请填写SMTP服务器地址",
				"smtpPort": {
					required: "请填写SMTP服务器端口",
					digits: "SMTP服务器端口必须为零或正整数"
				},
				"smtpUsername": "请填写SMTP用户名",
				"currencyType": "请选择货币种类",
				"currencySign": "请填写货币符号",
				"currencyUnit": "请填写货币单位",
				"storeAlertCount": {
					required: "请填写商品库存报警数量",
					digits: "商品库存报警数量必须为零或正整数"
				},
				"buildHtmlDelayTime": {
					required: "请填写HTML自动生成延时",
					digits: "HTML自动生成延时必须为零或正整数"
				}
			},
			submitHandler: function(form) {
				$(form).find(":submit").attr("disabled", true);
				form.submit();
			}
		});

        $('#colorPickerField').ColorPicker({
            color: '${(setting.luceneHighlighterColor)!"#f76120"}',
            onSubmit: function(hsb, hex, rgb, el) {
                $(el).val("#"+hex);
                $(el).ColorPickerHide();
            },
            onShow: function (colpkr) {
                $(colpkr).fadeIn(500);
                return false;
            },
            onHide: function (colpkr) {
                $(colpkr).fadeOut(500);
                return false;
            },
            onChange: function (hsb, hex, rgb) {
                $('#colorPickerSelected').css('color', '#' + hex);
            }
        });

        var $smtpFromMail = $("#smtpFromMail");
        var $smtpHost = $("#smtpHost");
        var $smtpPort = $("#smtpPort");
        var $smtpUsername = $("#smtpUsername");
        var $smtpPassword = $("#smtpPassword");
        var $toMailWrap = $("#toMailWrap");
        var $toMail = $("#toMail");
        var $mailTest = $("#mailTest");
        var $mailTestStatus = $("#mailTestStatus");

        //邮件测试
        $mailTest.click(function() {
            var $this = $(this);
            if ($this.val() == '邮箱测试') {
                $this.val("发送邮件");
                $toMailWrap.css("display","");
            } else {
                function valid(element) {
                    return $validateForm.validate().element(element);
                }
                $.ajax({
                    url: "mailTest.jhtml",
                    type: "POST",
                    data: {smtpFromMail: $smtpFromMail.val(), smtpHost: $smtpHost.val(), smtpPort: $smtpPort.val(), smtpUsername: $smtpUsername.val(), smtpPassword: $smtpPassword.val(), toMail: $toMail.val()},
                    dataType: "json",
                    cache: false,
                    beforeSend: function() {
                        if (valid($smtpFromMail) & valid($smtpHost) & valid($smtpPort) & valid($smtpUsername) & valid($toMail)) {
                            $mailTestStatus.html('<span class="loadingIcon">&nbsp;<\/span>');
                            $mailTest.attr('disabled',"true");
                        } else {
                            return false;
                        }
                    },
                    success: function(message) {
                        if(message.type =="SUCCESS"){
                            $mailTestStatus.html('<span class="loadingIcon">邮件发送成功！<\/span>');
                            $mailTest.attr('disabled',"true");
                        }else{
                            $mailTestStatus.html('<span class="loadingIcon">邮件发送失败！<\/span>');
                            $mailTest.removeAttr('disabled');
                        }
                    }
                });
            }
        });
	});
</script>
<style type="text/css">
#tabcontainer .l-tab-links ul{margin-left:160px;}
#tabcontainer{padding-top:20px;}
.l-tab-links{background:none;}
.l-tab-links li{margin: 0 0 0 12px;}
</style>
</head>
<body>
<form action="update.jhtml" method="post" class="validate" id="validateForm">
<div class="validateErrorContainer" id="validateErrorContainer" style="display: none;">
	<div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
	<ul style="display: none;"></ul>
</div>
<div id="tabcontainer" style="overflow:hidden;margin:3px;padding-bottom: 50px;">
	<!-- 站点设置 begin -->
	<div title="后台设置">
		<table width="600" align="center" class="inputTable2" style="display:table;">
			<tr>
				<th>网站名称：</th>
				<td><input type="text" class="formText" value="${(setting.name)!''}" name="name"></td>
			</tr>		
			<tr>
				<th>Logo: </th>
				<td>
					<div style="float:left;margin-right:20px;">
						<input type="hidden" size="50" id="logo" name="logo" value="${setting.logo}"/>
						<input type="button" value="选择图片" id="logoBtn" class="button browserButton">
					</div>
					<div style="margin-left:20px;">
						<a href="<@Pic pic=(setting.logo)!''/>" target="_blank">
							<img alt="预览区" class="preImg" src="<@Pic pic=(setting.logo)!''/>" />
						</a>
					</div>
				</td>
			</tr>
			<tr>
				<th>电话号码：</th>
				<td><input type="text" class="formText" value="${(setting.phone)!''}" name="phone"></td>
			</tr>
			<tr>
				<th>手机号码：</th>
				<td><input type="text" class="formText" value="${(setting.mobile)!''}" name="mobile"></td>
			</tr>
			<tr>
				<th>联系地址：</th>
				<td><input type="text" class="formText" value="${(setting.address)!''}" name="address"></td>
			</tr>
			<tr>
				<th>邮编：</th>
				<td><input type="text" class="formText" value="${(setting.zipCode)!''}" name="zipCode"></td>
			</tr>
			<tr>
				<th>联系人邮箱：</th>
				<td><input type="text" class="formText" value="${(setting.owner_email)!''}" name="owner_email"></td>
			</tr>
			<tr>
				<th>公司名称：</th>
				<td><input type="text" class="formText" value="${(setting.company)!''}" name="company"></td>
			</tr>
			<tr>
				<th>首页META关键词:</th>
				<td><input type="text" class="formText" style="width:400px;" 
					value="${(setting.metaKeywords)!''}" 
					name="metaKeywords"></td>
			</tr>
			<tr>
				<th>首页页面描述:</th>
				<td>
					<textarea rows="3" cols="70" name="metaDescription">
						${(setting.metaDescription)!''}
					</textarea>
				</td>
			</tr>
			<tr>
				<th>版权信息:</th>
				<td>
					<input type="text" name="copyright" class="formText"  value="${setting.copyright!''}"/>
				</td>
			</tr>
			<tr>
				<th>是否自动锁定账号：</th>
				<td><@u.radio name="isAdminLoginFailureLock" list={"true": "是", "false": "否"}
					value="${(setting.isAdminLoginFailureLock?string('true', 'false'))!'true'}" /></td>
			</tr>
			<tr>
				<th>连续登陆失败最大次数：</th>
				<td><input type="text" name="adminLoginFailureLockCount" class="formText {required: true, positiveInteger: true}" 
					value="${(setting.adminLoginFailureLockCount)!}" title="只允许输入正整数,当连续登录失败次数超过设定值时,系统将自动锁定该账号" /></td>
			</tr>
			<tr>
				<th>自动解锁时间：</th>
				<td><input type="text" name="adminLoginFailureLockTime" class="formText {required: true, digits: true}" 
					value="${(setting.adminLoginFailureLockTime)!}" title="只允许输入零或正整数,账号锁定后,自动解除锁定的时间,单位:分钟,0表示永久锁定" /></td>
			</tr>
			<tr>
				<th>默认图片: </th>
				<td>
					<div style="float:left;margin-right:20px;">
						<input type="hidden" size="50" id="defaultImg" name="defaultImg" value="${setting.defaultImg}"/>
						<input type="button" value="选择图片" id="defaultImgBtn" class="button browserButton">
					</div>
					<div style="margin-left:20px;">
						<a href="<@Pic pic=(setting.defaultImg)!''/>" target="_blank">
							<img alt="预览区" class="preImg_d" src="<@Pic pic=(setting.defaultImg)!''/>" />
						</a>
					</div>
				</td>
			</tr>
		</table>
	</div>
	
	<!-- 安全设置 -->
	<div title="安全设置">
		<table width="600" align="center" class="inputTable2" style="display:table;">
			<tr>
				<th>允许上传图片扩展名：</th>
				<td><input type="text" name="uploadImageExtension" class="formText" 
					value="${(setting.uploadImageExtension)!}" title="多个扩展名请以(,)分隔" />
					(如果此处不填，则默认不能上传文件)
				</td>
			</tr>
			<tr>
				<th>允许上传Flash扩展名：</th>
				<td><input type="text" name="uploadFlashExtension" class="formText" 
					value="${(setting.uploadFlashExtension)!}" title="多个扩展名请以(,)分隔" />
					(如果此处不填，则默认不能上传文件)
				</td>
			</tr>
			<tr>
				<th>允许上传媒体扩展名：</th>
				<td><input type="text" name="uploadMediaExtension" class="formText" 
					value="${(setting.uploadMediaExtension)!}" title="多个扩展名请以(,)分隔" />
					(如果此处不填，则默认不能上传文件)
				</td>
			</tr>
			<tr>
				<th>允许上传文件扩展名：</th>
				<td><input type="text" name="uploadFileExtension" class="formText" 
					value="${(setting.uploadFileExtension)!}" title="多个扩展名请以(,)分隔" />
					(如果此处不填，则默认不能上传文件)
				</td>
			</tr>
			<tr>
				<th>图片上传路径：</th>
				<td><input type="text" style="width:300px" name="imageUploadPath" class="formText" 
					value="${(setting.imageUploadPath)!}"/>
				</td>
			</tr>
			<tr>
				<th>Flash上传路径：</th>
				<td><input type="text" style="width:300px" name="flashUploadPath" class="formText" 
					value="${(setting.flashUploadPath)!}"/>
				</td>
			</tr>
			<tr>
				<th>媒体上传路径：</th>
				<td><input type="text" style="width:300px" name="mediaUploadPath" class="formText" 
					value="${(setting.mediaUploadPath)!}" />
				</td>
			</tr>
			<tr>
				<th>文件上传路径：</th>
				<td><input type="text" style="width:300px" name="fileUploadPath" class="formText" 
					value="${(setting.fileUploadPath)!}" />
				</td>
			</tr>
			<tr>
				<th>文件上传最大值：</th>
				<td><@u.select list={"0":"禁止上传","512":"512KB","1024":"1M","2048":"2M","3072":"3M","5120":"5M","-1":"不限制"} 
					name="uploadLimit" value="${(setting.uploadLimit)!''}" />
				</td>
			</tr>
			<tr>
				<th>静态资源路径: </th>
				<td>
					<input type="text" name="staticPath" class="formText"
						value="${(setting.staticPath)!''}"/>
				</td>
			</tr>
			<tr>
				<th>静态资源地址: </th>
				<td>
					<input type="text" name="staticUrl" class="formText"
						value="${(setting.staticUrl)!''}"/>
				</td>
			</tr>
		</table>
	</div>
		
	<!-- 站点设置 -->
	<div title="站点设置">
		<table width="600" align="center" class="inputTable2" style="display:table;">
			<tr>
				<th>域名</th>
				<td>
					<input type="text" name="domain" class="formText" value="${(setting.domain)!''}"/>
					(不包含http://)
				</td>
			</tr>	
			<tr>
				<th>IP</th>
				<td>
					<input type="text" name="domainAlias" class="formText" value="${(setting.domainAlias)!''}"/>
					(不包含http://)
				</td>
			</tr>	
			<tr>
				<th>端口</th>
				<td>
					<input type="text" name="port" class="formText" value="${(setting.port)!''}"/>
				</td>
			</tr>	
			<tr>
				<th>是否自动锁定账号：</th>
				<td><@u.radio name="isLoginFailureLock" list={"true": "是", "false": "否"}
					value="${(setting.isLoginFailureLock?string('true', 'false'))!'true'}" /></td>
			</tr>
			<tr>
				<th>连续登陆失败最大次数：</th>
				<td><input type="text" name="loginFailureLockCount" class="formText {required: true, positiveInteger: true}" 
					value="${(setting.loginFailureLockCount)!}" title="只允许输入正整数,当连续登录失败次数超过设定值时,系统将自动锁定该账号" /></td>
			</tr>
			<tr>
				<th>自动解锁时间：</th>
				<td><input type="text" name="loginFailureLockTime" class="formText {required: true, digits: true}" 
					value="${(setting.loginFailureLockTime)!}" title="只允许输入零或正整数,账号锁定后,自动解除锁定的时间,单位:分钟,0表示永久锁定" /></td>
			</tr>
			<tr>
				<th>创建商品索引目录路径：</th>
				<td><input type="text" name="luceneGoodsIndexPath" class="formText {required: true}" value="${(setting.luceneGoodsIndexPath)!}" /></td>
			</tr>
			<tr>
				<th>启用关键字搜索高亮显示：</th>
				<td>
				<@u.radio name="luceneEnableHighlighter" list={"true": "是", "false": "否"} value="${((setting.luceneEnableHighlighter)!'true')?string('true', 'false')}" />
				</td>
			</tr>
			<tr>
				<th id="colorPickerSelected" style="padding-left:5px;color:${(setting.luceneHighlighterColor)!"#f76120"}" title="搜索关键字高亮显示颜色"><b>搜索关键字高亮显示颜色：</b></th>
				<td>
                    <input type="text" name="luceneHighlighterColor" class="formText" maxlength="7" id="colorPickerField" value="${(setting.luceneHighlighterColor)!"#f76120"}">
				</td>
			</tr>
            <tr>
                <th>获取物流信息API地址：</th>
                <td><input type="text" name="deliveryApi"
                           class="formText {required: true}" value="${(setting.deliveryApi)!''}" /></td>
            </tr>
            <tr>
                <th>获取物流信息网站会员ID：</th>
                <td><input type="text" name="deliveryId"
                           class="formText {required: true}" value="${(setting.deliveryId)!''}" /></td>
            </tr>
            <tr>
                <th>获取物流信息加密字符串：</th>
                <td><input type="text" name="deliverySecret"
                           class="formText {required: true}" value="${(setting.deliverySecret)!''}" /></td>
            </tr>
			<!--<tr>
				<th>地图中心点默认精度: </th>
				<td>
					<input type="text" name="longitude" class="formText {number:true}" value="${(setting.longitude)!''}"/>
				</td>
			</tr>
			<tr>
				<th>地图中心点默认纬度: </th>
				<td>
					<input type="text" name="latitude" class="formText {number:true}" value="${(setting.latitude)!''}"/>
				</td>
			</tr>
			<tr>
				<th>百度开放平台AK: </th>
				<td>
					<input type="text" name="ak" class="formText" value="${(setting.ak)!''}"/>
				</td>
			</tr>-->
		</table>
	</div>
    <!-- 邮件设置 -->
    <div title="邮箱设置">
        <table width="600" align="center" class="inputTable2" style="display:table;">
            <tr>
                <th>发件人邮箱：</th>
                <td><input type="text" name="smtpFromMail" id="smtpFromMail"
                           class="formText {required: true}" value="${(setting.smtpFromMail)!''}" /></td>
            </tr>
            <tr>
                <th>SMTP服务器地址：</th>
                <td><input type="text" name="smtpHost" id="smtpHost"
                           class="formText {required: true}" value="${(setting.smtpHost)!''}" /></td>
            </tr>
            <tr>
                <th>SMTP服务器端口：</th>
                <td><input type="text" name="smtpPort" id="smtpPort"
                           class="formText {required: true}" value="${(setting.smtpPort)!''}" /></td>
            </tr>
            <tr>
                <th>SMTP用户名：</th>
                <td><input type="text" name="smtpUsername" id="smtpUsername"
                           class="formText {required: true}" value="${(setting.smtpUsername)!''}" /></td>
            </tr>
            <tr>
                <th>SMTP密码：</th>
                <td><input type="password" name="smtpPassword" id="smtpPassword"
                           class="formText {required: true}" value="${(setting.smtpPassword)!''}" /></td>
            </tr>
            <tr>
                <th>邮箱配置测试：</th>
                <td>
					<span id="toMailWrap" style="display:none;">
					<div>收件人邮箱: </div>
					<input type="text" id="toMail" name="toMail" class="formText {email: true}" maxlength="200" />
					</span>
                    <input type="button" id="mailTest" class="formButton" value="邮箱测试" hidefocus />
                    <span id="mailTestStatus"></span>
                </td>
            </tr>
        </table>
    </div>
	<!-- 其他设置 -->
	<div title="其他设置">
		<table width="600" align="center" class="inputTable2" style="display:table;">
			<tr>
				<th>货币符号：</th>
				<td><input type="text" name="currencySign" 
					class="formText {required: true}" value="${(setting.currencySign)!''}" /></td>
			</tr>
			<tr>
				<th>货币单位：</th>
				<td><input type="text" name="currencyUnit" 
					class="formText {required: true}" value="${(setting.currencyUnit)!''}" /></td>
			</tr>
			<tr>
				<th>商品价格精确位数：</th>
				<td><@u.select list={"0": "无小数位", "1":"1位小数", "2":"2位小数", "3":"3位小数", "4":"4位小数"} 
					name="priceScale" value="${(setting.priceScale)!''}"/></td>
			</tr>
			<tr>
				<th>商品价格精确方式：</th>
				<td><@u.select_map list=DictionaryUtils.getAllRoundType() name="priceRoundType" value="${setting.priceRoundType!''}"/></td>
			</tr>
			
			<!-- 其他设置 -->
			<tr>
				<th>相册备份Url：</th>
				<td><input type="text" name="albumBackupUrl" 
					class="formText {required: true}" value="${(setting.albumBackupUrl)!''}" /></td>
			</tr>
			<tr>
				<th>相册还原Url</th>
				<td><input type="text" name="albumRestoreUrl" 
					class="formText {required: true}" value="${(setting.albumRestoreUrl)!''}" /></td>
			</tr>
			<tr>
				<th>数据库备份Url：</th>
				<td><input type="text" name="dbBackupUrl" 
					class="formText {required: true}" value="${(setting.dbBackupUrl)!''}" /></td>
			</tr>
			<tr>
				<th>数据库还原Url：</th>
				<td><input type="text" name="dbRestoreUrl" 
					class="formText {required: true}" value="${(setting.dbRestoreUrl)!''}" /></td>
			</tr>
		</table>
	</div>
</div>
</form>
</body>
</html>